<?php
/**
 * DEPRECATED
 * This file was used for extract the similar artist from the database and add them to a relation database
 * But the structure of the database has changed so this file isn't necessary anymore
 */
//Make a connection to the database
mysql_connect('sql.ewi.tudelft.nl','ikemusic2','1234567890');
mysql_select_db('ikemusic2');
//fetch the similir artists
$query='SELECT id,Similar1,Similar2,Similar3,Similar4,Similar5 FROM Artist';

$result=mysql_query($query);
while($row=  mysql_fetch_array($result)){
    $query2="SELECT id FROM Artist WHERE name =  '".$row[1]."'  OR name =  '".$row[2]."' OR name =  '".$row[3]."' OR name =  '".$row[4]."' OR name =  '".$row[5]."'";

    $result2=mysql_query($query2);
    $similar1=$similar2=$similar3=$similar4=$similar5=0;
    $i=1;
    //Insert the link between the similar artists and the artist
    while($row2=  mysql_fetch_array($result2)){
        $var='similar'.$i;
        $$var=$row2[0];
        $i++;
    }
    $query3="INSERT INTO Similar (`ArtistID` ,`Similar1ID` ,`Similar2ID` ,`Similar3ID` ,`Similar4ID` ,`Similar5ID`) VALUES ('".$row[0]."',  '".$similar1."',  '".$similar2."',  '".$similar3."',  '".$similar4."',  '".$similar5."');";
    mysql_query($query3);  
}
mysql_close();
?>